/**
 * Created by Administrator on 2019/8/30.
 */


//验证用户名：必填，必须是数字字母组成，长度在6-12字符
function check_telno(){
    var flag =false;
    var telnoElement = document.querySelector("input[name='telno']");//获得手机号元素控件<input />
    var telno = telnoElement.value;  //获得手机号的值
    var telno_tip= telnoElement.parentElement.previousElementSibling.firstElementChild;
    if(telno == null || telno ==""){
        telno_tip.innerText="手机号不能为空";
    }else if( !/^[0-9]{11}$/.test(telno)  ){
        telno_tip.innerText="手机号错误"
    } else{
        telno_tip.innerText="";
        flag = true;
    }
    return flag;
}


function check_code(){
    if(check_telno()) {
        var flag = false;
        var codeElement = document.querySelector("input[name='code']");//获得验证码元素控件<input />
        var code = codeElement.value;  //获得验证码的值
        var code_tip = codeElement.parentElement.previousElementSibling.previousElementSibling.firstElementChild;
        if (code == null || code == "") {
            code_tip.innerText = "验证码不能为空";
        } else if (!/^[0-9A-Za-z]{4}$/.test(code)) {
            code_tip.innerText = "验证码错误";
        } else {
            code_tip.innerText = "";
            flag = true;
        }
        return flag;
    }
}